package com.rjkj.medicalwaste.viewmodels

import androidx.lifecycle.MutableLiveData
import com.rjkj.medicalwaste.base.BaseViewModel
import com.rjkj.medicalwaste.base.addOneGarbage
import com.rjkj.medicalwaste.bean.GarbageBean
import com.rjkj.medicalwaste.bean.GarbageStatus
import com.rjkj.medicalwaste.bean.MedicalWasteType
import com.rjkj.medicalwaste.bean.UserBean
import com.rjkj.medicalwaste.repository.GarbageRepository
import com.rjkj.medicalwaste.utils.TimeUtils

class CollectOneViewModel(private val garbageRepository: GarbageRepository) : BaseViewModel() {
    val preCode = MutableLiveData("")
    var time = ""
    var weight = "0.0"

    /**
     * 预制标签添加
     * @param code String
     * @param weight String
     * @param medicalWasteType MedicalWasteType
     * @param hospitalIdStr String
     * @param user UserBean
     * @param nurse UserBean
     * @param department UserBean
     * @return GarbageBean
     */
    suspend fun addGarbage2(
        serialNum: String,
        code: String,
        weight: String,
        medicalWasteType: MedicalWasteType,
        hospitalIdStr: String,
        user: UserBean,
        nurse: UserBean,
        department: UserBean,
    ): GarbageBean? {
        val findGarbageByCode2 = garbageRepository.findGarbageByCode2(code)
        if (findGarbageByCode2 == null) {
            return addOneGarbage(
                code = code,
                weight = weight,
                medicalWasteType = medicalWasteType,
                hospitalIdStr = hospitalIdStr,
                user = user,
                nurse = nurse,
                department = department,
                garbageDeviceSN = serialNum,
                garbageCount = 0,
                hospitalName = user.hospitalName
            )
        } else {
            return null
        }

    }


}